import request from '@/utils/request'

export function getNoticeList(params) {
  return request({
    url: '/notice/list',
    method: 'get',
    params,
    transformResponse: [function(data) {
      const newJson = data.replace(/\"id\":(\d+)/g, '"id":"$1"')
      const res = JSON.parse(newJson)
      return res
    }]
  })
}

export function getMineNoticeList(params) {
  return request({
    url: '/notice/banner_mine/list',
    method: 'get',
    params,
    transformResponse: [function(data) {
      const newJson = data.replace(/\"id\":(\d+)/g, '"id":"$1"')
      const res = JSON.parse(newJson)
      return res
    }]
  })
}

export function getOfficialContent(params) {
  return request({
    url: '/check/get_official_content',
    method: 'get',
    params
  })
}

export function getQueryExchange(params) {
  return request({
    url: '/check/query_exchange',
    method: 'get',
    params
  })
}

export function getCheckGetPayChannel(params) {
  return request({
    url: '/check/get_pay_channel',
    method: 'get',
    params
  })
}

export function xhrPostRecommend(data) {
  const { exchangeId, type } = data
  return request({
    url: `/check/operate_exchange/${exchangeId}/${type}`,
    method: 'put',
    data
  })
}

export function xhrPostUpdatePayChannel(data) {
  return request({
    url: '/check/update_pay_channel',
    method: 'post',
    data
  })
}

export function getNoticeDynamic(params) {
  return request({
    url: '/notice/dynamic/get',
    method: 'get',
    params
  })
}

export function updateNoticeList(data) {
  return request({
    url: '/notice',
    method: 'post',
    data
  })
}

export function updateMineNoticeList(data) {
  return request({
    url: '/notice/banner_mine/update',
    method: 'post',
    data
  })
}

export function updateOfficialContent(data) {
  return request({
    url: '/check/update_official_content',
    method: 'post',
    data
  })
}

export function getOfficialComment(params) {
  return request({
    url: '/check/get_official_comment',
    method: 'get',
    params
  })
}

export function dynamicGetRobotUserIds(params) {
  return request({
    url: '/dynamic/get_robot_user_ids',
    method: 'get',
    params
  })
}

export function pushissue(data) {
  return request({
    url: '/check/issue',
    method: 'post',
    data
  })
}

export function pushcomment(data) {
  return request({
    url: '/check/issue',
    method: 'post',
    data
  })
}

export function dynamicCommentIssue(data) {
  return request({
    url: `/dynamic/comment/issue/?userId=${data.commentUserId}`,
    method: 'post',
    data
  })
}

export function deletecomment(data) {
  return request({
    url: '/check/comments/' + data.userId + '/' + data.commentId,
    method: 'delete',
    data
  })
}

export function updateOfficialSwitch(data) {
  return request({
    url: '/anchor/update/official/switch',
    method: 'post',
    data
  })
}

export function getOfficialSwitch(data) {
  return request({
    url: '/check/get_official_switch',
    method: 'get',
    data
  })
}

export function updateNoticeDynamic(data) {
  return request({
    url: '/notice/dynamic/update',
    method: 'post',
    data
  })
}

export function deleteNoticeList(data) {
  return request({
    url: '/notice/delete',
    method: 'delete',
    data
  })
}

export function deleteMineNoticeList(data) {
  const { noticeId } = data
  return request({
    url: `/notice/banner_mine/${noticeId}`,
    method: 'delete',
    data
  })
}

export function deleteNoticeDynamic(noticeId) {
  return request({
    url: '/notice/dynamic/delete/' + noticeId,
    method: 'delete'
  })
}

export function getRecommendSteamerList(params) {
  return request({
    url: '/notice/recommend/list',
    method: 'get',
    params
  })
}

export function getRecommendTopSwitch(params) {
  return request({
    url: '/check/recommend/top/switch',
    method: 'get',
    params
  })
}

export function getRecommendTopSwitchStatus(params) {
  return request({
    url: '/check/recommend/top/switch/status',
    method: 'get',
    params
  })
}

export function addRecommendSteamer(data) {
  return request({
    url: '/notice/recommend/add',
    method: 'post',
    data
  })
}

export function deleteRecommendSteamer(data) {
  return request({
    url: '/notice/recommend/delete',
    method: 'delete',
    data
  })
}

export function getChannelList(params) {
  return request({
    url: '/channels/list',
    method: 'get',
    params,
    transformResponse: [function(data) {
      const newJson = data.replace(/\"id\":(\d+)/g, '"id":"$1"')
      const res = JSON.parse(newJson)
      return res
    }]
  })
}

export function updateChannelList(data) {
  return request({
    url: '/channels/update',
    method: 'post',
    data
  })
}

export function deleteChannelList(data) {
  return request({
    url: '/channels/delete',
    method: 'delete',
    data
  })
}

export function editChannelStatus(data) {
  return request({
    url: '/channels/status',
    method: 'put',
    data
  })
}

export function getUpgradeList(params) {
  return request({
    url: '/appVersion/list',
    method: 'get',
    params,
    transformResponse: [function(data) {
      const newJson = data.replace(/\"id\":(\d+)/g, '"id":"$1"')
      const res = JSON.parse(newJson)
      return res
    }]
  })
}

export function updateUpgradeList(data) {
  return request({
    url: '/appVersion/update',
    method: 'post',
    data
  })
}

export function deleteUpgradeList(data) {
  return request({
    url: '/appVersion/delete',
    method: 'delete',
    data
  })
}

// 鉴黄设置
export function xhrPornIdentifyUpdate(data) {
  return request({
    url: '/setting/porn_identify/update',
    method: 'post',
    data
  })
}

// 女用户补贴身份设置
export function xhrRewardProvinceUpdate(data) {
  return request({
    url: '/check/reward/province/list',
    method: 'post',
    data
  })
}

// 鉴黄设置列表
export function xhrPornIdentifyList() {
  return request({
    url: '/setting/porn_identify/list',
    method: 'get'
  })
}

// 女用户补贴省份
export function xhrRewardProvinceList() {
  return request({
    url: '/check/reward/province/list',
    method: 'get'
  })
}

// 权重设置
export function xhrWeightUpdate(data) {
  return request({
    url: '/setting/weight/update',
    method: 'post',
    data
  })
}

// 权重设置列表
export function xhrWeightList() {
  return request({
    url: '/setting/weight/list',
    method: 'get'
  })
}

// 主播权重设置
export function xhrAnchorWeightUpdate(data) {
  return request({
    url: '/setting/anchor_weight/update',
    method: 'post',
    data
  })
}

// 主播权重设置列表
export function xhrAnchorWeightList() {
  return request({
    url: '/setting/anchor_weight/list',
    method: 'get'
  })
}

// 主播权重删除
export function xhrAnchorWeightDelete(data) {
  return request({
    url: '/setting/anchor_weight/delete',
    method: 'delete',
    data
  })
}

// 活动配置展示
export function xhrActivityGet() {
  return request({
    url: '/setting/activity/get',
    method: 'get'
  })
}

// 活动配置
export function xhrActivitySet(data) {
  return request({
    url: '/setting/activity/set',
    method: 'post',
    data
  })
}
